/**
* Casey Burkhardt
* CSC 2035 - Algorithms and Data Structures III
* Due: 09/22/2008
* AirportSecurityGUI.java - The primary class for the Airport Security Project
*/

import java.util.StringTokenizer;
import java.io.*;
import java.text.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.Timer;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.border.*;
import java.util.Random;

public class AirportSecurityGUI extends JApplet
{
	private static int START_TIME = 0;//sets the time (in minutes since midnight) that the simulation starts
	
	// Applet Width and Height
	private static int WINDOW_WIDTH = 800;
	private static int WINDOW_HEIGHT = 550;

	// Static Application Instance Data
	private int customersOut;
	private int time;

	// Application Timer Mechanism
	private Timer mainTimer;
	
	// Queue Structures
	private CircularArrayQueue notices;
	private CircularArrayQueue temporary;

	// JPanels
	private JPanel infoPanel;
	private JPanel welcomePanel;

	//Application GUI Instances
	private ImagePanel imagePanel;
	private ControlsPanel controls;
	JPanel customersInPanel;

	//Other GUI Components
	private JLabel currentTimeLabel;
	private JLabel passengersInQueueLabel;
	private JLabel welcomeLabel;
	private JTextField currentTime;
	private JTextField passengersInQueue;
	
 public void init()
{
	 // Welcome Panel Setup
	 welcomeLabel = new JLabel("Welcome to Airport Security by Casey Burkhardt.  Don't forget to remove your shoes!");
     welcomeLabel.setAlignmentX (Component.CENTER_ALIGNMENT);
     
     welcomePanel = new JPanel();
     welcomePanel.add(welcomeLabel);
     
     JPanel header =new JPanel();	
     header.add(welcomePanel);

     // Information Panel Setup
     currentTime = new JTextField();
     currentTime.setEditable(false);
     currentTime.setColumns(9);

     passengersInQueue = new JTextField();
     passengersInQueue.setEditable(false);
     passengersInQueue.setColumns(9);

	currentTimeLabel = new JLabel("Current time: ");
	passengersInQueueLabel = new JLabel("Customers Currently in Queue: ");
	currentTimeLabel.setLabelFor(currentTime);
	passengersInQueueLabel.setLabelFor(passengersInQueue);
		
		//panel to hold the clock and its label and customers
	infoPanel = new JPanel();
	infoPanel.setLayout(new GridLayout(0,2));
	infoPanel.add(currentTimeLabel);
	infoPanel.add(currentTime);
	infoPanel.add(passengersInQueueLabel);
	infoPanel.add(passengersInQueue);
	
	imagePanel = new ImagePanel(WINDOW_WIDTH=960, this);
	controls = new ControlsPanel(imagePanel, this);	
	controls.setBorder(BorderFactory.createLineBorder(Color.black,1));

	//body panel to hold the controls, clock, and customer count			
	JPanel mainPanel = new JPanel();
	mainPanel.setLayout(new GridLayout(1,3));
	mainPanel.add(infoPanel);
	mainPanel.add(controls);
	mainPanel.setBorder(BorderFactory.createLineBorder(Color.black,1));

	Container contentPane = getContentPane();
	contentPane.add(welcomePanel,BorderLayout.NORTH);
	contentPane.add(mainPanel,BorderLayout.CENTER);
	contentPane.add(imagePanel,BorderLayout.SOUTH);

	//Set Final Size of Applet
	setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
	}
		
	public void updateCustomerCount()
	{
		passengersInQueue.setText(Integer.toString(imagePanel.queueSize()));
	}
	
		public void updateClock(String in)
	{
		currentTime.setText(in);
	}

	
}//close  class



